package com.hj.aiminai.service;

import com.hj.aiminai.docment.Msg;
import com.hj.aiminai.repository.MsgReposttory;
import lombok.RequiredArgsConstructor;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MsgService {
    private final MsgReposttory msgReposttory;

    private final MongoTemplate mongoTemplatel;

    public List<Msg> findByConversationId(String conversationId){
        Query query = new Query();
        query.addCriteria(Criteria.where("conversationId").is(conversationId));
        return mongoTemplatel.find(query,Msg.class);
    }
}
